import instance from "@/config/axiosConfig.js";

const LoginApi = {
    login: (data) => {
        return instance.post("/sys/auth/login", data).then(res => {
            return res.data
        });
    },
    getImageCaptcha: () => {
        return instance.get("/sys/captcha/createImageCaptcha", {responseType: "blob"}).then(res => {
            let reader = new FileReader();
            reader.readAsDataURL(res.data);
            return new Promise((resolve) => {
                reader.onload = function () {
                    resolve({captcha: reader.result, nonce: res.headers.get('X-Nonce')});
                }
            });
        });
    }
}

export default LoginApi;
